package com.ss.android.m.a;

import android.os.Handler;
import android.os.HandlerThread;
import android.os.Message;
import android.util.Log;

public abstract class a {
    public static String k;
    public static String l;
    public static String m;

    static {
        k = "seek_time";
        l = "play_url";
        m = "FINISH_op";
    }

    private final Object a;
    public com.ss.android.m.c.aa j;
    public int n;
    public com.ss.android.m.aa o;
    public com.ss.android.m.b.a p;
    public boolean q;

    public a() {

        this.a = new Object();
        this.n = 201;
        this.q = false;
        this.j = this.a(this.a(), new b(this));
        this.o();
    }

    public abstract com.ss.android.m.c.aa a(com.ss.android.m.c.a.a arg1, Handler arg2);

    public abstract com.ss.android.m.c.a.a a();

    final void a(int arg3) {
        Object v1 = this.a;
        synchronized (v1) {
            this.n = arg3;
        }
    }

    public void a(int arg4, Exception arg5) {
        if (this.p != null) {
            Log.d(this.p.a, "onPlayerException what = " + arg4 + " e.getMessage =  " + arg5.getMessage());
        }
    }

    public void a(long arg4) {
        if (this.p != null) {
            Log.d(this.p.a, "onBufferingUpdate percent = " + arg4);
        }
    }

    public void a(String arg4) {
        if (this.q) {
            this.o();
        }

        Message v0 = this.o.obtainMessage(107);
        v0.getData().putString(l, arg4);
        v0.sendToTarget();
        if (this.p != null) {
            Log.d(this.p.a, "doSetData url =" + arg4);
        }
    }

    public final void a(boolean arg3) {
        if (!this.q) {
            this.o.obtainMessage(100).sendToTarget();
            if (this.p != null) {
                this.p.a(arg3);
            }
        }
    }

    public final void b(boolean arg3) {
        if (!this.q) {
            this.o.obtainMessage(101).sendToTarget();
            if (this.p != null) {
                this.p.b(arg3);
            }
        }
    }

    public void b() {
        if (this.p != null) {
            Log.d(this.p.a, "finishStart");
        }

        this.a(206);
    }

    public void b(int arg4, int arg5) {
        if (this.p != null) {
            Log.d(this.p.a, "onInfo what = " + arg4 + " extra = " + arg5);
        }
    }

    private void c(boolean arg4) {
        this.o.obtainMessage(102).sendToTarget();
        if (this.p != null) {
            Log.d(this.p.a, "doReset isReleaseAll =" + arg4);
        }
    }

    public void c(int arg4, int arg5) {
        if (this.p != null) {
            Log.d(this.p.a, "onError what = " + arg4 + " extra = " + arg5);
        }

        this.a(200);
    }

    public void d() {
        if (this.p != null) {
            this.p.a();
        }

        this.a(209);
    }

    public void e() {
        this.o();
        this.c(false);
        this.a(201);
    }

    public void g() {
        if (!this.q) {
            this.b(true);
            this.c(true);
            this.q = true;
            this.o.obtainMessage(103).sendToTarget();
            if (this.p != null) {
                this.p.c(true);
            }
        }
    }

    public void i() {
        if (!this.q) {
            this.o.obtainMessage(104).sendToTarget();
            if (this.p != null) {
                Log.d(this.p.a, "doPrepared");
            }
        }
    }

    public void j() {
        if (this.p != null) {
            Log.d(this.p.a, "finishPrepared");
        }

        this.a(205);
    }

    public final void o() {
        this.q = false;
        com.ss.android.m.c.aa v0 = this.j;
        if (v0.f == null) {
            v0.f = new HandlerThread("VideoManager");
            v0.f.start();
            v0.e = new com.ss.android.m.aa(v0.f.getLooper(), ((com.ss.android.m.aa.a$a) v0));
        }

        this.o = v0.e;
    }
}

